import { reactive } from "vue"

export default function(){
    const arrRemoveDup = (array:any) => {
        return Array.from(new Set(array))
    }
    const reDupArray = (array:any,col:string) => {
        let reDupList = reactive([])
        for(const [key,value] of Object.entries(array.value)){
            reDupList.push(value[col])
        }
        reDupList=Array.from(new Set(reDupList))
        return reDupList
    }
    const checkTableEmpty = <T>(table:T) => {
        let EmptyCount = {}
        let totalEmpty = 0
        for(const[key,item] of Object.entries(table)){
            let rowEmptyCount = 0
            for(const [key,value] of Object.entries(item)){
                if(value === ''){
                    rowEmptyCount = rowEmptyCount + 1 
                    totalEmpty = totalEmpty + 1
                } else {}
            }
            EmptyCount[key]=rowEmptyCount
        }
        return {"totalEmpty":totalEmpty,"EmptyCount":EmptyCount}
    }

    return { arrRemoveDup,reDupArray,checkTableEmpty }
}
